﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace canyinguanlixitong
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void tabPage1_Click(object sender, EventArgs e)
        {

        }
        string strconn = "Data Source=.;Initial Catalog=Supermarket management system;Integrated Security=True";

        public void search()
        {
            DataSet dd = new DataSet("wo");
            SqlConnection conn = new SqlConnection(strconn);
            conn.Open();
            string sql = @"SELECT   UserTpye.userName,UserTpye.userBorn, VIPuser.vipMorey
  FROM      VIPuser CROSS JOIN
                  UserTpye";
            SqlDataAdapter a = new SqlDataAdapter(sql, conn);
            a.Fill(dd, "wo");
            dgvjiaoban.DataSource = dd.Tables["wo"];

        }
        private void Form1_Load(object sender, EventArgs e)
        {
            jiaoban();
            search();

            //band();
        }
        DataSet ds = new DataSet("Up");
        //public void band()
        //{
        //    SqlConnection conn = new SqlConnection(strconn);
        //    conn.Open();
        //    string sql = "select id from [User]";
        //    SqlDataAdapter a = new SqlDataAdapter(sql, conn);
        //    a.Fill(ds, "Up");
        //    comboBox1.DataSource = ds.Tables["Up"];
        //    comboBox1.ValueMember = "id";
        //    comboBox1.DisplayMember = "id";
        //}

        public void jiaoban()
        {
            SqlConnection conn = new SqlConnection(strconn);
            conn.Open();
            string sql = "select spJia from dbo.commodity where spID=2";
            SqlCommand cmd = new SqlCommand(sql, conn);
            SqlDataReader reader = cmd.ExecuteReader();
            if (reader.Read())
            {
                this.label25.Text = reader["spJia"].ToString();

            }
        }
        private void buttonjiaoban_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (this.tbxshangjiao.Text != "")
            {
                double num1 = Convert.ToDouble(this.tbxshangjiao.Text);
                double num = Convert.ToDouble(this.label25.Text);
                this.label25.Text = Convert.ToString(Convert.ToDouble((num - num1)));
            }
            if (this.tbx下放.Text != "")
            {
                double num1 = Convert.ToDouble(this.tbx下放.Text);
                double num = Convert.ToDouble(this.label25.Text);
                this.label25.Text = (num + num1).ToString();
            }
        }

        private void buttonqueding_Click(object sender, EventArgs e)
        {
            DialogResult DR = MessageBox.Show("确定交班吗？", "提示", MessageBoxButtons.OKCancel);
            if (DR == DialogResult.OK)
            {
                MessageBox.Show("成功吗");
                this.Close();
            }
        }

        private void buttonquxiao_Click(object sender, EventArgs e)
        {
            DialogResult DR = MessageBox.Show("确定取消交班吗？", "提示", MessageBoxButtons.OKCancel);
            if (DR == DialogResult.OK)
            {
                MessageBox.Show("取消成功");
                this.Close();
            }
        }
    }
}
